package com.insurance.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/10/29 9:59
 * Description:时间转换工具类
 * Version: V1.0
 */
public class ConversionDateUtils {
    /**
     * 日期转字符串
     * @param date
     * @return
     */
    public static String conversionDateStringUtils(Object date){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String strDate=simpleDateFormat.format(date);
        return strDate;
    }

    /**
     * 字符串转日期
     * @param date
     * @return
     */
    public static Date conversionDateUtils(String date){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date strDate= null;
        try {
            strDate = simpleDateFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return strDate;
    }
    /**
     * 字符串转日期
     * @param date
     * @return
     */
    public static Date conversionSqlDateUtils(String date){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
        Date strDate= null;
        try {
            strDate = simpleDateFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return strDate;
    }
}
